home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / News / Alexandra.0.82 / Source / NiceStuff.subproj / MiscAppFontDefaults.m < prev    next >
Encoding:
Text File  |  1996-01-30  |  1.6 KB  |  49 lines

  1.  
  2. #import "MiscAppFontDefaults.h"
  3.  
  4. //--------------------------------------------------------------------------------------
  5.     @implementation Application(MiscAppFontDefaults)
  6. //--------------------------------------------------------------------------------------
  7.     
  8.     /*" Extension of the methods of the #MiscAppDefaults category. Allows for saving
  9.         font information in the defaults database. N.B.: The name of the font must
  10.         not be longer than 300 characters. "*/
  11.  
  12. //--------------------------------------------------------------------------------------
  13.     - (Font *)defaultFont:(const char *)defName;
  14. //--------------------------------------------------------------------------------------
  15.     
  16.     /*" Returns the font stored in the defaults database with the name #defName 
  17.         "*/
  18.  
  19.     {
  20.     const char    *defValue;
  21.     char        fontName[300];
  22.     float        fontSize;
  23.     
  24.     defValue=[NXApp defaultValue:defName];
  25.     if(!defValue)
  26.         return nil;
  27.     sscanf(defValue,"%s %f",fontName,&fontSize);
  28.     return [Font newFont:fontName size:fontSize];
  29.     }
  30.  
  31.  
  32. //--------------------------------------------------------------------------------------
  33.     - setDefault:(const char *)defName toFont:(Font *)font;
  34. //--------------------------------------------------------------------------------------
  35.  
  36.     /*" Stores the font in the default database. "*/
  37.  
  38.     {
  39.     char    defValue[300];
  40.     
  41.     sprintf(defValue,"%s %fpt",[font name],[font pointSize]);
  42.     [NXApp setDefault:defName to:defValue];    
  43.     return self;
  44.     }
  45.     
  46. //--------------------------------------------------------------------------------------
  47.     @end
  48. //--------------------------------------------------------------------------------------
  49.